package Recommendation;

import User.User;

public class OneSlope implements Recommendation
{
	private User[] users;
	private int id1;
	private int id2;
	
	public OneSlope(User[] users, int id1, int id2)
	{
		this.users = users;
		this.id1 = id1;
		this.id2 = id2;
	}
	
	@Override
	public double calc()
	{
		double total = 0;
		int amount = 0;
		
		for (User u : users)
		{
			double rating1 = u.getRating(id1);
			double rating2 = u.getRating(id2);
			
			if (rating1 != -1 && rating2 != -1)
			{
				total += rating1 - rating2;
				amount++;
			}
		}
		
		return total / amount;
	}
}
